<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
    <meta name="csrf-token" content="{{ csrf_token() }}">
	<link rel="stylesheet" href="/shop/style/css/ch-ui.admin.css">
    <link rel="stylesheet" href="/shop/style/font/css/font-awesome.min.css">
    <link rel="stylesheet" href="/shop/style/css/page.css">
    <script type="text/javascript" src="/shop/style/js/jquery.js"></script>
    <script type="text/javascript" src="/shop/style/js/ch-ui.admin.js"></script>
    <link rel="stylesheet" href="/houtai/layui/css/layui.css">
    <script src="/houtai/layui/layui.js"></script>
    <link rel="stylesheet" href="/shop/style/serachalbelSelect/searchableSelect.css">
    <script type="text/javascript" src="/shop/style/serachalbelSelect/jquery.searchableSelect.js"></script>

    <style>
        .tc{
            text-align:center;
        }
        a{
            color:#1963aa;
        }
    </style>
</head>
<body>
    <!--面包屑导航 开始-->
    <div class="crumb_warp">
        <i class="fa fa-home"></i> <a href="#">首页</a> &raquo; <a href="#">商城管理</a> &raquo; 下架商品列表
    </div>
    <!--面包屑导航 结束-->

	<!--结果页快捷搜索框 开始-->
	<div class="search_wrap">
        <form action="" method="post">
            <table class="search_tab">
                <tr>

                    <th width="70">关键字:</th>
                    <td><input type="text" name="keywords" placeholder="请输入商品名" value="{{$request->keywords}}"></td>
                    <th width="70">货源ID:</th>
                    <td><input type="text" name="gid" placeholder="请输入货源ID" value="{{$request->gid}}"></td>
                    <th width="120">选择分类:</th>
                    <td style="width:160px">
                        <select name="pid" lay-verify="" lay-search id="ftype">
                            <option value="">==请选择==</option>
                            @foreach($all_list as $fvo)
                                <option value="{{$fvo->id}}" @if($request['pid'] == $fvo->id) selected @endif><?php echo str_repeat("&nbsp;",substr_count($fvo->path,',')*3);?>|--{{$fvo->name}}</option>
                            @endforeach
                        </select>
                    </td>

                    <th width="120">选择品牌:</th>
                    <td style="width:160px">
                        <select name="bid" lay-verify="" lay-search id="compayId">
                            <option value="">==请选择==</option>
                            @foreach($brand as $fvo)
                                <option value="{{$fvo->id}}" @if($request['bid'] == $fvo->id) selected @endif>{{$fvo->name_cny}}</option>
                            @endforeach
                        </select>
                    </td>

                    <th width="120">选择店铺:</th>
                    <td style="width:160px">
                        <select name="mid" lay-verify="" lay-search id="merchant">
                            <option value="">==请选择==</option>
                            @foreach($merchant as $fvo)
                                <option value="{{$fvo->id}}" @if($request['mid'] == $fvo->id) selected @endif>{{$fvo->shop}}</option>
                            @endforeach
                        </select>
                    </td>
                    <th width="120">是否同步:</th>
                    <td>
                        <select id="sub_dpi" name="is_e" lay-verify="" lay-search >
                            <option value="">==请选择==</option>
                            <option value="1" @if($request['is_e'] == 1) selected @endif>是</option>
                            <option value="2" @if($request['is_e'] == 2) selected @endif>否</option>
                        </select>
                    </td>
                    <td><input type="submit" name="sub" value="查询"></td>
                </tr>
            </table>
        </form>
    </div>
    <!--结果页快捷搜索框 结束-->

    <!--搜索结果页面 列表 开始-->
    <form action="#" method="post">
        <div class="result_wrap">
            <div class="result_content">
                <table class="list_tab">
                    <tr>
                        <th>ID</th>
                        <th>商品名</th>
                        <th>成本价</th>
                        <th>销售价</th>
                        <th>店铺总数</th>
                        <th>类型</th>
                        <th>品牌</th>
                        <th>是否同步</th>
                        {{--<th>状态</th>--}}
                        <th>创建时间</th>
                        <th>操作</th>
                    </tr>
                    @if($list->isEmpty())
                        <tr>
                            <td colspan="11" class="tc">暂无数据</td>
                        </tr>
                    @else
                        @foreach ($list as $v)
                            @if($v->status == 4)
                            <tr style="background-color:#99CCCC;">
                            @else
                            <tr >
                            @endif
                                <td>{{$v->id}}</td>
                                <td>{{$v->name}}</td>
                                <td>{{$v->price}}</td>
                                <td>
                                    @if($v->is_chage == 1)
                                        <span style="color:red">{{$v->new_sell_price}}</span>
                                    @else
                                        {{$v->sell_price}}
                                    @endif
                                </td>
                                <td>{{$v->mer_num}}</td>
                                <td>{{$v->tname}}</td>
                                <td>{{$v->bname}}</td>
                                <td>@if($v['state'] == 1)是 @else 否 @endif</td>
                                {{--<td>@if($v['status'] == 1)正常 @elseif($v['status'] == 4) APP后台已删除@endif</td>--}}
                                <td>{{$v->created_at}}</td>
                                <td>
                                    <a href="javascript:void(0);" onClick="config({{$v->id}})">上架</a>
                                </td>
                            </tr>
                        @endforeach
                    @endif

                </table>
            </div>
            <div id="pull_right">
                <!--分页写法-->
                <div class="pull-right">
                    {{ $list->appends(['keywords'=>$request->keywords,'bid'=>$request->bid,'mid'=>$request->mid,'pid'=>$request->pid,'is_e'=>$request->is_e])->render() }}
                </div>
            </div>
        </div>
        <form>
            <div style="margin-top:8px;margin-left:18px">
                第&nbsp;<input type="" name="page" value="{{$pages}}" style="width:50px;border:1px solid #ddd;line-height:70px;text-align:center;height:30px;border-radius:1px">&nbsp;页
                &nbsp;&nbsp;&nbsp;&nbsp;<button class="layui-btn layui-btn-sm" lay-submit lay-filter="selectsub">跳转</button>
            </div>
            <input type="hidden" name="keywords" value="{{$request->keywords}}">
            <input type="hidden" name="bid" value="{{$request->bid}}">
            <input type="hidden" name="mid" value="{{$request->mid}}">
            <input type="hidden" name="pid" value="{{$request->pid}}">
            <input type="hidden" name="is_e" value="{{$request->is_e}}">
        </form>


    </form>
    <!--搜索结果页面 列表 结束-->

    <script>
        $(function(){
            $('#compayId').searchableSelect();
            $('#ftype').searchableSelect();
            $('#merchant').searchableSelect();
        })
        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });

        //上架
        function config(id){
            var page = $('input[name=page]').val();
            var keywords = $('input[name=keywords]').val();
            var bid = $('input[name=bid]').val();
            var mid = $('input[name=mid]').val();
            var pid = $('input[name=pid]').val();
            var is_e = $('input[name=is_e]').val();
            layui.use('layer', function() {
                layer.confirm('确定上架?', {icon: 3, title: '提示'}, function (index) {
                    $.ajax({
                        url:'/shop/good/good_up',
                        type:'post',
                        data:{id:id},
                        async:false,
                        success:function(msg){
                            layer.msg(msg['msg'],{time:3000},function(){
                                location.href='/shop/good/index_down?page='+page+'&keywords='+keywords+'&bid='+bid+'&mid='+mid+'&pid='+pid+'&is_e='+is_e;
                            });
                        },
                    })
                });
            });
        }

    </script>

</body>
</html>